<%@page import="bean.Advertisement"  %>
<%@page import="bean.CartItem"  %>
<%@page import="bean.TransactedItem"  %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%@ include file="/title.html" %>
</head>
<body>
<table width="100%">
<%@ include file="/header.jsp" %>

<tr valign="top"><td align="center" height="300px">
<table width="100%">

<tr valign="top" height="50px">
<td align="center">
<%@ include file="/headerLinks.jsp" %>
</td>
</tr>
<tr><td align="center" height="40px" colspan="2" valign="top"><h3>Purchased Items</h3></td></tr>
<% if(request.getAttribute("message") != null) { %>
<tr><td align="center" style="color:red"><%= request.getAttribute("message") %></td></tr>
<% } %>

<%if(null != request.getAttribute("TransactedItem")) { 
%>	
<tr>
	<td align="center">
	<table  width="60%" style="text-align:left">
		<tr>
			<td>No.</td>
			<td>Item</td>
			<td>Description</td>
			<td>Seller Information</td>
			<td>Quantity</td>
			<td>Price</td>			
			<td>Total</td>
		</tr>
<%		TransactedItem aoTransactedItem[] = (TransactedItem[])request.getAttribute("TransactedItem");
		Advertisement aoAdvert[] = (Advertisement[])request.getAttribute("Advertisement");
		int cartItemId = 0, itemId=0, quantityInCart = 0;
		int i,j;
		float total = 0;
		for(i=0;i<aoTransactedItem.length;i++) {
			
			
			itemId = aoTransactedItem[i].getItemId();
				
			quantityInCart = aoTransactedItem[i].getItemQuantity();
			total = (aoTransactedItem[i].getItemPrice()*quantityInCart);
			for(j=0;j<aoAdvert.length;j++) {
				if(aoAdvert[j].getItemId() == itemId) {
						break;
					}
				}
			
%>
	
		<tr>
			<td><%=i+1%></td>
			<td><%=aoAdvert[j].getItemName() %></td>
			<td><%=aoAdvert[j].getItemDescription() %></td>
			<td><%=aoAdvert[j].getSellerInfo() %></td>
			<td><%=aoTransactedItem[i].getItemPrice() %></td>
			<td><%=aoTransactedItem[i].getItemQuantity() %>
			<td><%=total %></td>			
		</tr>
	
<%	} %>
	</table>
	</td>
</tr>
<%} %>

</table>
</td>
</tr>

<%@ include file="/bottom.html" %>
</table>
</body>
</html>